<%@ page language="java" import="java.util.*,java.net.*" contentType="text/html; charset=utf-8"  pageEncoding="utf-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Student Login page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	
	<script type="text/javascript" src="js/jquery-1.8.0.js"></script>
	<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript">
			$(document).ready(function(){
				$("#submit").click(function(){
					$.ajax({
					type: "POST", //访问WebService使用Post方式请求
					url: "inteface/stuLogin", //调用WebService的地址和方法名称组合 ---- WsURL/方法名
					data: $("#userform").serialize(), //这里是要传递的参数，格式为 data: "{paraName:paraValue}",下面将会看到
					dataType: 'json', //WebService 会返回Json类型
					success: function(json) {
							if (json.result == "success") {
								alert(json.data.callback + "?uid=" + json.data.uid)
								location.href= (json.data.callback + "?uid=" + json.data.uid)
							}else{
								alert(json.data)
								validate_refrash()
							}
						},
					error:function(json){
								alert("unknown error")
								validate_refrash()
						}
					});
				});
			});
			function validate_refrash(){
				$("#validateCode").attr("src", "validate_code?" + Math.floor(Math.random()*100))
			}
			
	</script>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <form id="userform">
    <center>
    <table>
	    	<tr>
	    		<td>user name:<input name="username"  type="text" value="" /></td>
	    	</tr>
			<tr>    	
				<td> password :<input name="password" type="password" value=""/></td>
			</tr>
			
			<tr>    	
				<td> validate :<input name="validate" type="text" value="" style="width: 100"/>
				<img id="validateCode" title="点击刷新验证码"  src="validate_code"  onclick="validate_refrash()"/></td>
			</tr>
			<tr>
	    		<td>
	    				accessToken:<input name="accessToken" type="text" value="" />
	    		</td>
	    	</tr>
			<tr>
	    		<td>
	    				<input id="submit" type="button" value="login" />
	    		</td>
	    	</tr>
    </table>
    </center>
    </form>
  </body>
</html>
